﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DesignPatternDemoCApp.Behavioral.IteratorPattern
{
    /// <summary>
    /// 部队队列具体聚合类--相当于具体聚合类ConcreteAggregate
    /// </summary>
    public sealed class ConcreteTroopQueue : ITroopQueue
    {
        private string[] collection;

        /// <summary>
        /// 具体聚合类构造函数
        /// </summary>
        public ConcreteTroopQueue()
        {
            collection = new string[] { "黄飞鸿", "方世玉", "洪熙官", "严咏春" };
        }

        public Iterator GetIterator()
        {
            return new ConcreteIterator(this);
        }

        public int Length
        {
            get { return collection.Length; }
        }

        public string GetElement(int index)
        {
            return collection[index];
        }
    }
}
